/**
 * 
 */
var local_data = 1;
var _left_nav,_home_view;
var _href_suffix = '';
var _image_suffix = 'static_resources/images/';
var SYS_BASE_DATA ;
var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
//加权因子
var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
//校验位
var parity = [ '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
//解压文件显示ico
var fileIcon = {'pdf':'f07.png','docx':'f05.png','doc':'f05.png','png':'f08.png','txt':'f03.png','ppt':'f04.png','gif':'f08.png','jpg':'f08.png','ico':'f08.png','zip':'f02.png','rar':'f02.png','gzip':'f02.png'};
if(typeof(SYS_BASE_DATA) == 'undefined'){
	//ajax
	$.ajax({
       	url:basePath+'sys/SysBaseExtdata/list',
    	data:{},
    	type:'post',
    	dataType:'json',
    	async:false,
    	success:function(result){
    	        if(typeof(result)!='undefined'){
    	        	SYS_BASE_DATA = result;
    	        }
    		},
    		complete:function(){
    		}
        });
	
}
var _local_loan_status = {
	0:'录入',
	1:'待提交'	,
	2:'待审核',
	3:'待考察',
	4:'待审批',
	5:'待复核',
	6:'待放款',
	7:'待回收',
	8:'已结清',
	'-1':'中止',
	'-2':'退回'
};


var _local_loan_progress_status = {
		0:'正常',
		1:'回退',
		2:'中止',
		3:'恢复'
};

var _local_contract_status = {
		'1':'待申请',
		'2':'待签订',
		'3':'待确认',
		'4':'已签订',
		'5':'已作废'
};

var _local_sys_log_type = {
		'1':'登录',
		'2':'查询',
		'3':'操作'
};
var _local_sys_web_type = {
		'0':'正常',
		'1':'禁用'
};

var _local_client_subtle_type = {
		1:'敏感信息',
		2:'员工',
		3:'特别关注'
};

//贷款操作
var _local_loan_opt = {
		1:[{'title':'删除','func':'loan_del'},{'title':'编辑','func':'loan_edit'},{'title':'进度','func':'loan_process'},{'title':'中止','func':'loan_stop'}],
		2:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}],
		3:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}],
		4:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}],
		5:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}],
		6:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}],
		7:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}],
		8:[{'title':'查看','func':'loan_query'},{'title':'进度','func':'loan_process'}]
}

var _local_contract_opt = {
		1:[{'title':'申请','func':'contract_edit'},{'title':'录入担保','func':'contract_guarantee'},{'title':'作废','func':'loan_stop'},{'title':'进度','func':'loan_process'}],
		2:[{'title':'查看','func':'contract_query'},{'title':'打印','func':'contract_print'},{'title':'签订','func':'contract_sign'},{'title':'上传','func':'contract_loading'},{'title':'进度','func':'loan_process'}],
		3:[{'title':'查看','func':'contract_query'},{'title':'打印','func':'contract_print'},{'title':'进度','func':'loan_process'}],
		4:[{'title':'查看','func':'contract_query'},{'title':'打印','func':'contract_print'},{'title':'进度','func':'loan_process'}],
		5:[{'title':'查看','func':'contract_query'},{'title':'进度','func':'loan_process'}]
}

var _loacl_contract_check_opt = {
		5:[{'title':'复核','func':'loan_review'},{'title':'进度','func':'loan_process'}],
		6:[{'title':'查看','func':'contract_query'},{'title':'进度','func':'loan_process'}]
};

var _loacl_payment_opt = {
		6:[{'title':'放款','func':'loan_payment'},{'title':'进度','func':'loan_process'}],
		7:[{'title':'查看','func':'contract_query'},{'title':'进度','func':'loan_process'}]
};
//默认操作
var _local_default_opt = [{'title':'编辑','func':'default_edit'},{'title':'删除','func':'default_del'}];
var _local_default_query_opt = [{'title':'查看','func':'default_query'}];



//生成默认的href
var _set_default_href = function(id,_local_default_opt_){
	if(typeof(_local_default_opt_)=='undefined'){
		_local_default_opt_ = _local_default_opt;
	}
	if(typeof(_local_default_opt_)!='undefined' && _local_default_opt_.length>0){
		var href_str = '';
		for(var key in _local_default_opt_){
			var a_href = _local_default_opt_[key];
			href_str = href_str + _set_one_href(a_href,id)+'&nbsp;';
		}
		return href_str;
	}
	return '';
};

//生成默认的href
/*var _set_default_href = function(id){
	if(typeof(_local_default_opt)!='undefined' && _local_default_opt.length>0){
		var href_str = '';
		for(var key in _local_default_opt){
			var a_href = _local_default_opt[key];
			href_str = href_str + _set_one_href(a_href,id)+'&nbsp;';
		}
		return href_str;
	}
	return '';
};*/

//生成HREF
var _set_href = function(status,id,_local_opt){
	var m_local_opt = _local_opt;
	if((typeof m_local_opt)=='undefined'){
		m_local_opt = _local_loan_opt;
	}
	var href_arr = m_local_opt[status];
	if(href_arr && href_arr.length>0){
		var href_str = '';
		for(var key in href_arr){
			var a_href = href_arr[key];
			href_str = href_str + _set_one_href(a_href,id)+'&nbsp;';
		}
		return href_str;
	}
	return '';
};



var _set_one_href = function(a_href,id){
	var ids;
	if($.isArray(id)){
		ids = id.join(',');
	}else{
		ids = id;
	}
	if(a_href){
		return '<a href="javascript:void(0);"    onclick="'+a_href['func']+'('+ids+');"'+'   title="'+a_href['title']+'"  class="tablelink" >'+a_href['title']+'</a>';
	}
	return '';
};


var _do_nav_left = function(){
	window.frames['leftFrame']._do_nav_left();
};

var _do_goto_right = function(url){
	$('#rightFrame').attr('src',url);
	//window.frames['rightFrame'].src = url;
};

var logout = function(){

	$.ajax({
       	url:'sys/Manage/logout',
    	data:{},
    	type:'post',
    	dataType:'json',
    	async:false,
    	success:function(result){
    	        if(typeof(result)!='undefined' && result.state == 200){
    	             window.location.reload(true);
    	        }else{
    	        	alert(result.message);
    	        }
    		},
    		complete:function(){
    		}
        });
};

var _set_page_message = function(total,page){
	return '<div class="message">共<i class="blue">'+total+'</i>条记录，当前显示第&nbsp;<i class="blue">'+page+'&nbsp;</i>页</div>'
}

var _set_left_nav = function(nav) {
	var dd = "<dd>";
	var img = '<img src="' + basePath + _image_suffix + nav.icon + '"'
			+ 'title="' + nav.title + '" />';
	var dd_div = '<div class="title"><span>' + img + '</span>' + nav.title
			+ '</div>';
	var ul = "";
	var left_nav = nav.child;
	if (left_nav) {
		ul = '<ul class="menuson">';
		for ( var key in left_nav) {
			var one = left_nav[key];
			var li = '<li><cite></cite><a href="' + basePath + _href_suffix + one.href
					+ '" target="rightFrame">' + one.title + '</a><i></i></li>';
			ul = ul + li;
		}

		ul = ul + '</ul>';
	}
	dd = dd + dd_div + ul + '</dd>';
	return dd;
};

var _set_top_nav = function(nav, index, selected) {
	var li = "<li>";
	var selected_ = "";
	if (selected) {
		selected_ = selected_ + 'class="' + selected + '"';
	}
	var rightFrame = "";
	if (nav.target) {
		rightFrame = ' target="' + nav.target + '" ';
	}
	var index_sign = ' index_sign="' + index + '" ';
	var suffix_href = '';
	if (nav.href && nav.child && nav.href!="#") {
		var url = basePath + _href_suffix + nav.href;
		suffix_href = '<a href="javascript:void(0)" onclick=_reflash_left('
		+ index + ',"' + url + '")>';	
		
	} 
	if(nav.href && !nav.child && nav.href!="#"){
		suffix_href = '<a href="' + basePath + _href_suffix + nav.href + '"'
		+ rightFrame + selected_ + index_sign + ' >';
	}
	if((!nav.href || nav.href=='' || nav.href == '#' ) && nav.child){
		suffix_href = '<a href="javascript:void(0)" onclick=_reflash_left('
			+ index + ')>';
	}
	var img = '<img src="' + basePath + _image_suffix + nav.icon + '"'
			+ 'title="' + nav.title + '" />';
	li = li + suffix_href + img + '<h2>' + nav.title + '</h2></a></li>';
	return li;
};

//隐藏左边
var hide_left = function(){
	$('#centerFrameset').attr('cols','0,*');
}

//打开左边
var show_left = function(){
	$('#centerFrameset').attr('cols','187,*');
}

var array_to_obj = function(array, name, value){
	var obj = {};
	for ( var arr in array) {
		var objName = array[arr][name];
		var objValue = array[arr][value];
		if(!objValue || objValue.length < 1) continue;
		if(obj[objName] != undefined){
			obj[objName] = obj[objName] + ',' + objValue;
		}else{
			obj[objName] = objValue;
		}
	}
	return obj;
};

var _set_query_conditions = function(aoData,array){
	var set_obj = array_to_obj(array,'name','value');
	for(var key in set_obj){
		var one = {'name':key,'value':set_obj[key]};
		aoData.push(one);
	}
	return aoData;
}


/*var _nav_top_ = [

{
	id : 1,
	icon : 'icon01.png',
	title : '我的桌面',
	href : '/manage/index.jsp',
	target : 'rightFrame',
	child : [{
		id : 11,
		icon : 'leftico03.png',
		title : '个人管理',
		child : [ {
			id : 111,
			href : '/user/user_main_detail.jsp',
			title : '个人信息',
			target : 'rightFrame'
		}, {
			id : 112,
			href : '/user/userModifyPassword.jsp',
			title : '修改密码',
			target : 'rightFrame'
		}]
	} ]
}, {
	id : 2,
	icon : 'icon07.png',
	title : '贷款管理',
	target : 'rightFrame',
	child : [ {
		id : 21,
		icon : 'leftico03.png',
		title : '贷款申请',
		child : [ {
			id : 211,
			href : '/loan/applyLoanList_.jsp',
			title : '新增贷款',
			target : 'rightFrame'
		}, {
			id : 212,
			href : '/client/client_subtle_list.jsp',
			title : '敏感信息',
			target : 'rightFrame'
		}, {
			id : 213,
			href : '/loan/suspendLoanList.jsp',
			title : '中止贷款',
			target : 'rightFrame'
		}]
	}, {
		id : 22,
		icon : 'leftico03.png',
		title : '贷款审批',
		target : 'rightFrame',
		child : [ {
			id : 221,
			href : '/loan/auditLoanList.jsp',
			title : '待审核贷款',
			target : 'rightFrame'
		}, {
			id : 222,
			href : '/loan/inspectLoanList.jsp',
			title : '待考察贷款',
			target : 'rightFrame'
		}, {
			id : 223,
			href : '/loan/approveLoanList.jsp',
			title : '待审批贷款',
			target : 'rightFrame'
		} ]
	}, {
		id : 23,
		icon : 'leftico03.png',
		title : '贷款发放',
		child : [ {
			id : 231,
			href : '/loan/contract_manage_list.jsp',
			title : '合同管理',
			target : 'rightFrame'
		}, {
			id : 232,
			href : '/loan/loan_check_list.jsp',
			title : '放款复核',
			target : 'rightFrame'
		}, {
			id : 233,
			href : '/loan/paymentLoanList.jsp',
			title : '确认放款',
			target : 'rightFrame'
		} ]
	}, {
		id : 24,
		icon : 'leftico03.png',
		title : '贷款回收',
		child : [ {
			id : 241,
			href : '/loan/repaymentLoanList.jsp',
			title : '待收贷款',
			target : 'rightFrame'
		}, {
			id : 242,
			href : '/loan/repaymentDetailLoanList.jsp',
			title : '收款明细',
			target : 'rightFrame'
		}, {
			id : 243,
			href : '/loan/overdueLoanList.jsp',
			title : '逾期贷款',
			target : 'rightFrame'
		} ]
	}, {
		id : 25,
		icon : 'leftico03.png',
		title : '贷后管理',
		child : [ {
			id : 241,
			href : '/other/error.jsp',
			title : '风险预警',
			target : 'rightFrame'
		}, {
			id : 242,
			href : '/loan/collectionTaskList.jsp',
			title : '催收分配',
			target : 'rightFrame'
		}, {
			id : 243,
			href : '/loan/collectionResultList.jsp',
			title : '催收结果',
			target : 'rightFrame'
		} ]
	} ]
},

{
	id : 4,
	icon : 'icon02.png',
	title : '报表统计',
	child : [ {
		id : 41,
		icon : 'leftico03.png',
		title : '业务报表',
		child : [ {
			id : 411,
			href : '/other/error.jsp',
			title : '贷款统计表',
			target : 'rightFrame'
		}, {
			id : 412,
			href : '/other/error.jsp',
			title : '贷款收益明细表',
			target : 'rightFrame'
		}, {
			id : 413,
			href : '/other/error.jsp',
			title : '审批情况汇总',
			target : 'rightFrame'
		}, {
			id : 414,
			href : '/other/error.jsp',
			title : '放款汇总',
			target : 'rightFrame'
		}, {
			id : 415,
			href : '/other/error.jsp',
			title : '待定。。。',
			target : 'rightFrame'
		} ]
	}, {
		id : 42,
		icon : 'leftico03.png',
		title : '财务报表',
		child : [ {
			id : 421,
			href : '/other/error.jsp',
			title : '回款统计表',
			target : 'rightFrame'
		}, {
			id : 422,
			href : '/other/error.jsp',
			title : '放款统计表',
			target : 'rightFrame'
		}, {
			id : 423,
			href : '/other/error.jsp',
			title : '息费统计表',
			target : 'rightFrame'
		}, {
			id : 424,
			href : '/other/error.jsp',
			title : '待定。。。',
			target : 'rightFrame'
		} ]
	}, {
		id : 43,
		icon : 'leftico03.png',
		title : '业绩报表',
		child : [ {
			id : 431,
			href : '/other/error.jsp',
			title : '待定。。。',
			target : 'rightFrame'
		} ]
	} ]
}, {
	id : 3,
	icon : 'icon03.png',
	title : '工作计划',
	href : '/other/error.jsp',
	target : 'rightFrame',
	child : [ {
		id : 31,
		icon : 'leftico03.png',
		title : '我的计划',
		child : [ {
			id : 311,
			href : '/other/error.jsp',
			title : '本周计划',
			target : 'rightFrame'
		}, {
			id : 312,
			href : '/other/error.jsp',
			title : '待定。。。',
			target : 'rightFrame'
		}]
	} ]
}, {
	id : 5,
	icon : 'icon05.png',
	title : '文档管理',
	href : '/user/file.jsp',
	target : 'rightFrame',
	child : [ {
		id : 51,
		icon : 'leftico03.png',
		title : '客户资料',
		child : [ {
			id : 511,
			href : '/user/filelist.jsp',
			title : '客户信息资料',
			target : 'rightFrame'
		}, {
			id : 512,
			href : '/other/error.jsp',
			title : '贷款审核资料',
			target : 'rightFrame'
		}, {
			id : 513,
			href : '/other/error.jsp',
			title : '贷款考察资料',
			target : 'rightFrame'
		}, {
			id : 514,
			href : '/other/error.jsp',
			title : '合同信息资料',
			target : 'rightFrame'
		}]
	},{
		id : 52,
		icon : 'leftico03.png',
		title : '其他资料',
		child : [ {
			id : 611,
			href : '/other/error.jsp',
			title : '其他',
			target : 'rightFrame'
		}]
	}]
}, {
	id : 6,
	icon : 'icon04.png',
	title : '常用工具',
	href : '/other/tools.jsp',
	target : 'rightFrame',
	child : [ {
		id : 61,
		icon : 'leftico03.png',
		title : '常用工具',
		child : [ {
			id : 611,
			href : '/other/error.jsp',
			title : '记事本',
			target : 'rightFrame'
		}, {
			id : 612,
			href : '/other/error.jsp',
			title : '通讯录',
			target : 'rightFrame'
		}, {
			id : 613,
			href : '/other/error.jsp',
			title : '计算器',
			target : 'rightFrame'
		}]
	}]
}, {
	id : 7,
	icon : 'icon06.png',
	title : '系统设置',
	target : 'rightFrame',
	child : [ {
		id : 71,
		icon : 'leftico03.png',
		title : '系统管理',
		child : [ {
			id : 711,
			href : '/sys/dept_list.jsp',
			title : '组织架构',
			target : 'rightFrame'
		}, {
			id : 712,
			href : '/sys/sys_role_list.jsp',
			title : '角色管理',
			target : 'rightFrame'
		}, {
			id : 713,
			href : '/user/user_list_data_tables.jsp',
			title : '用户管理',
			target : 'rightFrame'
		}, {
			id : 714,
			href : '/sys/sys_post_list.jsp',
			title : '职位管理',
			target : 'rightFrame'
		}, {
			id : 715,
			href : '/sys/data_base_list.jsp',
			title : '数据字典',
			target : 'rightFrame'
		}, {
			id : 716,
			href : '/sys/sys_parameter_list.jsp',
			title : '系统参数',
			target : 'rightFrame'
		}, {
			id : 717,
			href : '/sys/module_list.jsp',
			title : '系统模块',
			target : 'rightFrame'
		}, {
			id : 718,
			href : '/sys/sys_web_list.jsp',
			title : '网点管理',
			target : 'rightFrame'
		}, {
			id : 719,
			href : '/sys/sys_log_list.jsp',
			title : '操作日志',
			target : 'rightFrame'
		}]
	}, {
		id : 72,
		icon : 'leftico03.png',
		title : '公告信息',
		child : [ {
			id : 721,
			href : '/other/error.jsp',
			title : '网站公告',
			target : 'rightFrame'
		} ]
	} ]
}

];*/

//执行孩子页面
$(function(){	
	//加载TOP
	//window.frames['topFrame']._do_nav_top();
	//加载LEFT
	//window.frames['leftFrame']._do_nav_left();
	//第一次加载桌面 全屏显示   window.parent.document.getElementsByTagName("frameset")[0].cols="0,*";
	
//	if(!_left_nav) {
//		//加载第一个 默认为菜单
//		_left_nav = _nav_top_[0].child;
//	}
	//第一次加载我们去初始化他的个人桌面就行了 其他不管
	if(!_home_view){
		_home_view = _nav_top_[0];
		//window.frames['leftFrame']._do_home_view_empty_left();
		//window.frames['topFrame']._do_home_view();
	}
});

